//
//  plaza_button.m
//  SoundPill
//
//  Created by 宋鹏鹏 on 15/6/9.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "plaza_button.h"

#define kDeviceHeight [UIScreen mainScreen].bounds.size.height
#define kDeviceWidth  [UIScreen mainScreen].bounds.size.width

#define kTitleScale 0.7
// 设置宽高
#define kMenuItemW kDeviceWidth*0.21
#define kMenuItemH 25

@implementation plaza_button

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 1.文字颜色
        [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        //self.userInteractionEnabled=NO;
        
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    
    [self setTitle:title forState:UIControlStateNormal];
}

- (void)setFrame:(CGRect)frame
{
    frame.size = CGSizeMake(kMenuItemW, kMenuItemH);
    [super setFrame:frame];
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat h = contentRect.size.height;
    CGFloat w = contentRect.size.width * kTitleScale;
    return CGRectMake(contentRect.size.width * 0.3, 0, w, h);
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat h = contentRect.size.height;
    CGFloat w = contentRect.size.width * 0.37;
    
    
    return CGRectMake(contentRect.size.width * 0.1, 0, w, h);
}
@end
